package com.bolt.report.definition;

import com.bolt.report.util.ToolUtil;

import java.io.Serializable;

public class PaperDefinition implements Serializable {

    private int leftMargin = 90;

    private int rightMargin = 90;

    private int topMargin = 72;

    private int bottomMargin = 72;

    private PaperType paperType;

    private int fixRows;

    private float width;

    private float height;

    private PrintOrder printOrderValue;


    private StyleDefinition columnHeaderStyle;

    public int getLeftMargin() {
        return leftMargin;
    }

    public void setLeftMargin(int leftMargin) {
        this.leftMargin = leftMargin;
    }

    public int getRightMargin() {
        return rightMargin;
    }

    public void setRightMargin(int rightMargin) {
        this.rightMargin = rightMargin;
    }

    public int getTopMargin() {
        return topMargin;
    }

    public void setTopMargin(int topMargin) {
        this.topMargin = topMargin;
    }

    public int getBottomMargin() {
        return bottomMargin;
    }

    public void setBottomMargin(int bottomMargin) {
        this.bottomMargin = bottomMargin;
    }

    public PaperType getPaperType() {
        return paperType;
    }

    public void setPaperType(PaperType paperType) {
        this.paperType = paperType;
    }

    public int getFixRows() {
        return fixRows;
    }

    public void setFixRows(int fixRows) {
        this.fixRows = fixRows;
    }

    public float getWidth(PaperSize.SizeUnit unit) {
        return ToolUtil.millimetersConvertUnit(this.width, unit);
    }

    public void setWidth(float width) {
        this.width = width;
    }

    public float getHeight(PaperSize.SizeUnit unit) {
        return ToolUtil.millimetersConvertUnit(this.height, unit);
    }

    public void setHeight(float height) {
        this.height = height;
    }

    public PrintOrder getPrintOrderValue() {
        return printOrderValue;
    }

    public void setPrintOrderValue(PrintOrder printOrderValue) {
        this.printOrderValue = printOrderValue;
    }

    public StyleDefinition getColumnHeaderStyle() {
        return columnHeaderStyle;
    }

    public void setColumnHeaderStyle(StyleDefinition columnHeaderStyle) {
        this.columnHeaderStyle = columnHeaderStyle;
    }

    public float getContextHeight(PaperSize.SizeUnit unit) {
        int margin = getTopMargin() + getBottomMargin();
        float height = PrintOrder.VERTICAL == getPrintOrderValue() ? this.height : this.width;
        return ToolUtil.millimetersConvertUnit(height - margin, unit);
    }
}